package com.lai.note.fragment;

import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lai.note.R;
import com.lai.note.adapter.CustomRecyclerAdapter;
import com.lai.note.util.ListAppUtil;

import java.util.List;

public class ListAppRecyclerViewFragment extends Fragment {

    public ListAppRecyclerViewFragment(){
        super(R.layout.listapp_recyclerview);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        RecyclerView recyclerView = getView().findViewById(R.id.appRecyclerView);

        List<PackageInfo> packages = ListAppUtil.getUserAppList(getActivity());
        CustomRecyclerAdapter adapter = new CustomRecyclerAdapter(packages);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(adapter);
    }
}
